import JSEncrypt from 'jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey =
`-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDGDxmixEdykG5KYBknvxdfA/ux
+HmG61ufo93KApDGM7gb6sPCZhcoaVhJXWegIQfSBB4+3o5HgGrUH92NUTBrDJ2g
N/VICdstazP1hahrrRAkAG922D77tQsgnlVhadOw1uDo9/nCP2NUYzYHZ9nMZiG8
idag4+7N8cAAofeflQIDAQAB
-----END PUBLIC KEY-----`
  // 'M343S24514234324'

const privateKey =`-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMYPGaLER3KQbkpg
GSe/F18D+7H4eYbrW5+j3coCkMYzuBvqw8JmFyhpWEldZ6AhB9IEHj7ejkeAatQf
3Y1RMGsMnaA39UgJ2y1rM/WFqGutECQAb3bYPvu1CyCeVWFp07DW4Oj3+cI/Y1Rj
Ngdn2cxmIbyJ1qDj7s3xwACh95+VAgMBAAECgYAIR9FWkMY77/XsfiAPHVooys3X
HwBVt7lY70zyiTDsWHU2FZahpgsJ0X2zc4hFlZvyF+H71uoz6xaMT9i/c8mGXVgh
cuuAhI0Vt12F85xEVfeC3c7Tsti7vsFdCNGW4b/a4B5fHu+2ItlvqHTb/uDUqu9Z
UCc5DJIxGVZRFFuHgQJBAPSJsr/G4Ep1vd8SQmVyAFbIveaWlzhO6Kxz2Wf1a2XR
8jVS8GgrWKTA68xJdvfsQvtgNJmbl4oGL/6hmfSPhS0CQQDPV68lf+3ous5uTgy2
nZJeg90x+x2BoDqyKE1cn4WWQBkTDLvlf3TzPyNGJtKcUtuoay2LRoJ04zqVXnSh
BFUJAkEArNshJXr5VOkBvEt176u0HaRsyDCu2Di/NBf4GApdTm4nnhXwplHtqRhO
FevgUsQJXRPWWranWgOhrYaiA0PoSQJATsypQNw0w60zRRKenEyYUxlUWGlyVlBZ
3lmYxSnPMEIeBXJiep8NCGEne8LHaifHWWOaRINAk0HEgv4J3yPxWQJABapRa4Y+
0Tj1ReaLbjAm2Zhk5m3Zf63lSWwHOR2v9pc2Z9CZDttalVse6hcEdpDipnxJjjXU
jH4Lvuz4OyYs6A==
-----END PRIVATE KEY-----`
  // 'SFDMSFLK34J32L4324='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}
